package JAVA300.第八章常用类;

public class TestString {
    public static void main(String[] args) {
        String str = "abc";
        String str1 = "def";

        String str2 = str +str1;
        String str3 = "abc"+"def";
        String str4 = "abcdef";
        System.out.println(str3 == str4);//true,str3 编译器做了优化 直接在编译的时候将字符串拼接
        System.out.println(str2 == str4);//false，str2仅仅保存地址 不知道存储的内容
        System.out.println(str2.equals(str4) );//true,对比数值
        System.out.println(str2);
    }
}
